package cn.iocoder.yudao.module.jifenyuan.controller.app.roomuserbind;

import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.room.RoomWithUsersDo;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.roomuserbind.RoomUserBindWithInfoDO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.jifenyuan.controller.app.roomuserbind.vo.*;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.roomuserbind.RoomUserBindDO;
import cn.iocoder.yudao.module.jifenyuan.convert.roomuserbind.RoomUserBindConvert;
import cn.iocoder.yudao.module.jifenyuan.service.roomuserbind.RoomUserBindService;

@Tag(name = "用户 APP - 记分员 房间与成员绑定")
@RestController
@RequestMapping("/jifenyuan/room-user-bind")
@Validated
public class AppRoomUserBindController {

    @Resource
    private RoomUserBindService roomUserBindService;

//    @PostMapping("/create")
//    @Operation(summary = "创建记分员 房间与成员绑定")
//
//    public CommonResult<Long> createRoomUserBind(@Valid @RequestBody AppRoomUserBindCreateReqVO createReqVO) {
//        return success(roomUserBindService.createRoomUserBind(createReqVO));
//    }
//
//    @PutMapping("/update")
//    @Operation(summary = "更新记分员 房间与成员绑定")
//
//    public CommonResult<Boolean> updateRoomUserBind(@Valid @RequestBody AppRoomUserBindUpdateReqVO updateReqVO) {
//        roomUserBindService.updateRoomUserBind(updateReqVO);
//        return success(true);
//    }
//
//    @DeleteMapping("/delete")
//    @Operation(summary = "删除记分员 房间与成员绑定")
//    @Parameter(name = "id", description = "编号", required = true)
//
//    public CommonResult<Boolean> deleteRoomUserBind(@RequestParam("id") Long id) {
//        roomUserBindService.deleteRoomUserBind(id);
//        return success(true);
//    }
//
//    @GetMapping("/get")
//    @Operation(summary = "获得记分员 房间与成员绑定")
//    @Parameter(name = "id", description = "编号", required = true, example = "1024")
//
//    public CommonResult<AppRoomUserBindRespVO> getRoomUserBind(@RequestParam("id") Long id) {
//        RoomUserBindDO roomUserBind = roomUserBindService.getRoomUserBind(id);
//        return success(RoomUserBindConvert.INSTANCE.convert(roomUserBind));
//    }
//
//    @GetMapping("/list")
//    @Operation(summary = "获得记分员 房间与成员绑定列表")
//    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
//
//    public CommonResult<List<AppRoomUserBindRespVO>> getRoomUserBindList(@RequestParam("ids") Collection<Long> ids) {
//        List<RoomUserBindDO> list = roomUserBindService.getRoomUserBindList(ids);
//        return success(RoomUserBindConvert.INSTANCE.convertList(list));
//    }
//
    @GetMapping("/page")
    @Operation(summary = "获得记分员 房间与成员绑定分页")
    @PreAuthenticated
    public CommonResult<PageResult<RoomWithUsersDo>> getRoomUserBindPage(@Valid AppRoomUserBindPageReqVO pageVO) {
        PageResult<RoomWithUsersDo> pageResult = roomUserBindService.getRoomUserBindPage(pageVO);
        return success(pageResult);
    }
    @GetMapping("/getRoomHistoryDetail")
    @Operation(summary = "获得记分员 房间与成员绑定分页")
    @PreAuthenticated
    public CommonResult<List<RoomUserBindWithInfoDO>> getRoomHistoryDetail(@RequestParam("roomId") Long roomId) {
        List<RoomUserBindWithInfoDO> roomDetail = roomUserBindService.getRoomDetail(roomId);
        return success(roomDetail);
    }

    @GetMapping("/getCount")
    @Operation(summary = "获得加入的房间数")
    @PreAuthenticated
    public CommonResult<Long> getCountByUserId() {

        return success(roomUserBindService.getCountByUserId());
    }


//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出记分员 房间与成员绑定 Excel")
//
//    @OperateLog(type = EXPORT)
//    public void exportRoomUserBindExcel(@Valid AppRoomUserBindExportReqVO exportReqVO,
//              HttpServletResponse response) throws IOException {
//        List<RoomUserBindDO> list = roomUserBindService.getRoomUserBindList(exportReqVO);
//        // 导出 Excel
//        List<AppRoomUserBindExcelVO> datas = RoomUserBindConvert.INSTANCE.convertList02(list);
//        ExcelUtils.write(response, "记分员 房间与成员绑定.xls", "数据", AppRoomUserBindExcelVO.class, datas);
//    }

}
